<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
{$meta}
<link type="text/css" rel="stylesheet" href="{$css_path}/global.css" />
<link type="text/css" rel="stylesheet" href="{$css_path}/style.css" />
</head><body>
<!--头部--> 
{include file="top.html"}
{include file="header.html"} 
<!--登录-->
<div id="main">
  <div class="q2a_detail_left">
    <div class="know_title">
      <div class="know_title_pic"> <img src="{$data.avatar_path}"/> </div>
      <div class="know_title_detail">
        <p id="q2a_name">{$data.name}</p>
        <p><a href="#">{$data.username}</a><span>&nbsp;发表于&nbsp;{$data.timeformat|floortime},&nbsp;{$data.answer_count}人回/{$data.view_count}人浏览</span></p>
      </div>
    </div>
    <div class="know_content_detail">
      <div class="content_detail_list"> {$data.content} </div>
      <div class="label">
        <div class="biaoqian">标签：</div>
        <p class="tags_list"> {if count($data.tags)>0}
          {foreach from=$data.tags item=tags} <a href='{$site_url}question/tag/{$tags.id}' title='{$tags.name}'>{$tags.name}</a> {/foreach}    
          {/if} </p>
      </div>
  
      
      <div class="yes_no">
        <ul>
          <li id="step"  onclick="add_votes('down')">(<span id="step_num"></span>)</li>
          <li id="support" onclick="add_votes('up')">(<span id="support_num"></span>)</li>
          <li id="star" onclick="collect_q2a({$data.id})">({$data.collects})</li>
        </ul>
            <div class="clear"></div>
      </div>
       <p id="msg" style="text-align:center;color:red"></p>
          <div class="clear"></div>
    </div>
    <!--    <div class="answer">
      <p><span>共有<span>3</span>个答案</span>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#">我要回答>></a></p>
    </div>-->
    <div class="other_answer"> {foreach from=$answer_list.top_answer item=answer}
      <div class="other_answer_list">
        <div class="answer_people"> <img src="{$answer.avatar_path}" alt="{$answer.username}"/> </div>
        <div class="answer_people_right">
          <p>{$answer.content}</p>
          <p>{$answer.username}<span>回答于&nbsp;&nbsp;&nbsp;{$comment.add_time|floortime}</span></p>
          <p style="font-weight:bolder;">- - -共有&nbsp;&nbsp;&nbsp;{$answer.comments_count} &nbsp;&nbsp;&nbsp;条评论- - -</p>
          {foreach from=$answer.comments item=comment}
          <p style=" color:#ff6600;"><img align="absmiddle" user="207467" class="SmallPortrait" title="{$comment.username}" alt="{$comment.username}" src="{$comment.avatar_path}" width="35" height="35">{$comment.username} 回复说：{$comment.content} <span>时间：{$comment.add_time|floortime}</span></p>
          {/foreach}
          <div class="votes" style="float: right;"> <span id="answer_message_{$answer.id}"></span> <span id="answer_votes_{$answer.id}"> <a href="javascript:add_answer_votes('up',{$answer.id} )">有帮助</a><em>({$answer.up_votes})</em>&nbsp;| <a href="javascript:add_answer_votes('down',{$answer.id} )">没帮助</a><em>({$answer.down_votes})</em>&nbsp;| </span> <a href="javascript:void(0);" id="replay_answer_{$answer.id}" class="replay_answer" title="{$answer.id}">回复</a><em>({$answer.comment_count})</em>&nbsp;|
            {if $data.user_id == $user.id}
            {if !count($top_answer)>0} <span class="top_span"><a href="javascript:answer_top({$answer.id})">置顶</a>&nbsp;|</span> {/if}
            {/if}
            
            {if $user.is_admin == 1} <a href="javascript:delete_answer({$answer.id})">删除</a>&nbsp;|
            
            {/if} </div>
            <div class="clear"></div>
        </div>
        
      </div>
      {/foreach}
      <div id="answer_list">
      {foreach from=$answer_list.common_answer item=answer}
      <div class="other_answer_list_other">
        <div class="answer_people"> <img src="{$answer.avatar_path}"/> </div>
        <div class="answer_people_right">
          <p>{$answer.content}</p>
          <p>{$answer.username}<span>回答于&nbsp;&nbsp;&nbsp;{$answer.add_time|floortime} </span></p>
          {if $answer.comments_count != 0}
          <p style="font-weight:bolder;">- - -共有&nbsp;&nbsp;&nbsp;{$answer.comments_count} &nbsp;&nbsp;&nbsp;条评论- - -</p>
          {/if}
          {if count($answer.comments)>0}
          {foreach from=$answer.comments item=comment}
          <p style=" color:#ff6600;"><img src="{$comment.avatar_path}"/>{$comment.content} <span>({$comment.add_time})by {$comment.username})</span></p>
          {/foreach}
          {/if}
          <div class="votes" style="float: right;"> <span id="answer_message_{$answer.id}"></span> <span id="answer_votes_{$answer.id}"> <a href="javascript:add_answer_votes('up',{$answer.id} )">有帮助</a><em>({$answer.up_votes})</em>&nbsp;| <a href="javascript:add_answer_votes('down',{$answer.id} )">没帮助</a><em>({$answer.down_votes})</em>&nbsp;| </span> <a href="javascript:void(0);" id="replay_answer_{$answer.id}" class="replay_answer" title="{$answer.id}">回复</a><em>({$answer.comment_count})</em>&nbsp;|
            {if $data.user_id == $user.id}
            {if !count($top_answer)>0} <span class="top_span"><a href="javascript:answer_top({$answer.id})">置顶</a>&nbsp;|</span> {/if}
            {/if}
            
            {if $user.is_admin == 1} <a href="javascript:delete_answer({$answer.id})">删除</a>&nbsp;|
            
            {/if} </div>
        </div>  <div class="clear"></div>
      </div>
    
      {/foreach} </div></div>
    <div>
      <input type="hidden" id="answer_category_id" value="{$data.category_id}"/>
      <input type="hidden" id="answer_parent_id" value="{$data.id}"/>
       <table style="width:100%">
          <tr>
            <td width="10%">留&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;言：</td>
            <td>  <textarea id='answer_content' name='content' style="width:80%"></textarea></td>
          </tr>
          <tr>
            <td>验&nbsp;证&nbsp;码：</td>
            <td><input type='text' id='captcha' name='captcha'  class='text'/></td>
          </tr>
            <tr>
            <td></td>
            <td>{$captcha}</td>
          </tr>
          <tr>
            <td></td>
            <td align="center"><input type='button' value=' 我要回答 ' id="answer_click" class='rndbutton'/><span class="answer_message"></span></td>
          </tr>
        </table>
     
      <br/>
    </div>
  </div>
  <div class="q2a_detail_right">
    <div class="want_question">
      <p>有什么技术问题吗？</p>
      <div><a href="{$site_url}question">我要提问</a></div>
    </div>
    <div class="another_questions">
      <div class="another_questions_top"><a href="#">氿上管理员</a>的其它问题<span><a href="{$site_url}question">全部问题>></a></span></div>
      <ul>
        {if count($user_related_questions)>0}
        {foreach from=$user_related_questions item=related_question}
        <li><img src="{$images_path}/point.png"/>&nbsp;&nbsp;<a href="{$related_question.url}" title="{$related_question.name}">{$related_question.name}</a>
          <p>({$related_question.answer_count}回/{$related_question.view_count}阅,{$related_question.add_time|floortime})</p>
        </li>
        {/foreach}
        {/if}
      </ul>
    </div>
    <div class="pic_size"><img src="{$images_path}/right_pic.jpg"/></div>
    <div class="another_questions">
      <div class="another_questions_top">类似问题<span><a href="{$site_url}question">全部问题>></a></span></div>
      <ul>
        {if count($category_related_questions)>0}
        {foreach from=$category_related_questions item=related_question}
        <li><img src="{$images_path}/point.png"/>&nbsp;&nbsp;<a href="{$related_question.url}" title="{$related_question.name}">{$related_question.name}</a>
          <p>({$related_question.answer_count}回/{$related_question.view_count}阅,{$related_question.add_time|floortime})</p>
        </li>
        {/foreach}
        {/if}
      </ul>
    </div>
    <div class="pic_size"><img src="{$images_path}/right_pic_last.jpg"/></div>
  </div>
</div>
<div class="clear"></div>
<div style="display:none">
  <div id="inline" style=" overflow:auto"> 
  {if count($user)>0}
    <form action="{$site_url}comment/add" method="post">
      <input name="question_id" type="hidden" value="{$data.id}"/>
      <input type="hidden" id="page" value="{$page_num}" name="page"/>
      <input class="commont_answer_id" type="hidden" name="parent_id"/>
      <textarea id='commont_content' name='content' style='width:360px;height:160px;'></textarea>
      <input type='submit' value=' 我要回复 '  class='rndbutton commont_click'/>
      <span class="commont_message"></span>
    </form>
    {else}
    请先登录,登录请<a href="{$site_url}user/login">点这里</a> {/if} </div>
</div>
<script type="text/javascript" src="{$js_path}/message.js"></script> 
<script type="text/javascript" src="{$js_path}/jquery.validate.js"></script> 
<script type="text/javascript" src="{$js_path}/jquery.validate.js"></script> 
<script type="text/javascript" src="{$js_path}/fancybox/jquery.fancybox-1.3.1.pack.js"></script> 
<link type="text/css" rel="stylesheet" href="{$js_path}/fancybox/fancybox.css" />
<script type="text/javascript" src="{$js_path}/jnotify/jNotify.jquery.js"></script> 
<link type="text/css" rel="stylesheet" href="{$js_path}/jnotify/jNotify.jquery.css" />
<script>           
function add_votes(act){  
  id = {$data.id};
  $.ajax({
	  type: 'post',
	  url: '{$site_url}q2a_ajax/get_votes',
	  data: 'id='+id+'&act='+act,
	  dataType: 'json',
	  beforeSend:function(XMLHttpRequest){
		  $("#msg").show().html("操作中... ...");
	   },
	  success: function(data){
		  if(data.message != ''){
			  var message = "<font color=\"red\">"+data.message+"</font>";
			  $("#msg").show().html(message).fadeOut(2000);
			  $('#support_num').text(data.up_votes);
		  	  $('#step_num').text(data.down_votes);
		  }
	  }
  });
}


/* 收藏商品 */
function collect_q2a(id)
{
 
	var title = $('#q2a_name').text();
	var url = '{$site_url}ajax/add_collect/';
	$.post(url, {'id':id,'type':'q2a','title':title}, function(data){
		$("#msg").show().html(data).fadeOut(2000);
	});
}


$(function(){
	$('.replay_answer').live('click',function(){
		$('.commont_answer_id').val($(this).attr('title'));
		$.fancybox({
			'content': $('#inline').html()
		})
	});
	
	 $.ajax({
		type: 'post',
		url: '{$site_url}q2a_ajax/get_votes',
		data: 'id='+{$data.id},
		dataType: 'json',
		beforeSend:function(XMLHttpRequest){
		  $("#msg").show().html("操作中... ...");
	   },
		success: function(data){
			$('#support_num').text(data.up_votes);
			$('#step_num').text(data.down_votes);
			$("#msg").show().html(data.message).fadeOut(2000);
		}
	});
	
	
	
	 $('#answer_click').click(function(){
		var answer_content = $('#answer_content').val();
		var parent_id = $('#answer_parent_id').val();
		var captcha = $('#captcha').val();
		var answer_category_id = $('#answer_category_id').val();
		if(answer_content ==''){
			$('.answer_message').show().html('<font color=red>评论内容不能为空</font>').fadeOut(3000);
		} else if(captcha == ''){
			$('.answer_message').show().html('<font color=red>验证码不能为空</font>').fadeOut(3000);
		}else{
			$.ajax({
				type: 'post',
				url: '{$site_url}q2a_ajax/add_answer',
				cache: false,
				data: 'content='+answer_content+'&parent_id='+parent_id+'&category_id='+answer_category_id+'&catpcha='+captcha,
				dataType: 'html',
				beforeSend:function(XMLHttpRequest){
					$(".answer_message").show().html("操作中... ...");
				},
				success: function(data){
					document.getElementById('captcha_change').src = '{$site_url}captcha/default?r='+Math.random();
					if(data == 0){
						$('.answer_message').show().html('<font color=red>验证码错误</font>').fadeOut(3000);
					}else{
						$("#answer_list").append(data);
						$('.answer_message').show().html('<font color=blue>添加成功</font>').fadeOut(3000);
					}
				}
			});
		}
	});
});

</script> 
<!--尾部--> 
{include file="footer.html"}
</body>
</html>
